<? 
	layout("/inc/win_layout.html",{title:sysTitle}){
?>
<div class="panel">
	<div class="panel-body pan" 
		style="margin-top: 15px; margin-left: 15px; margin-right: 15px; height: 450px;overflow :auto;">
		<div class="row" style="margin-bottom: 10px;width: 850px;" >
			<div class="col-lg-12">
			 <table class="table table-hover table-striped table-bordered table-advanced tablesorter mbn">
		      			 <thead>
		       			<tr id="boxTableOne"></tr>
				 </thead>
		   				<tbody id="roles"></tbody>
			 </table>
			</div>
		</div>
	</div>
</div>

<?} ?>
<script type="text/javascript">
var zTreeId = window.parent.getZTreeId();
	//查询角色
	$(function()  {
		queryRepository();
	});
	function queryRepository(){
			$.ajax({
			type : "post",
			data : {
			},
			url : "knowledgeEditDataQuerydomain.do",
			dataType : "json",
			beforeSend : function(XMLHttpRequest) {
			},
			success : function(data){
			//alert(JSON.stringify(data));
			$("#boxTableOne").html("");
      		  var tableOne = "";   
      		 		tableOne +="<th width='50px' style='text-align:center'><input type='checkbox' onclick='selectAll(this)'  /></th>"
						     +"<th width='50px'  style='text-align:center'>序号</th>"
	      		  			 +"<th style='text-align:center'>知识库名</th>"
	      		  			 +"<th style='text-align:center'>知识库描述</th>"
				 $("#boxTableOne").append(tableOne);
			
			var str = "";   
      		 $("#roles").html("");
       			for(var i=0;i<data.length;i++){
           		 str+="<tr>"
           		 	+"<td style='text-align:center'><input type='checkbox' name='checkall' value='"+data[i].classesId+"'/></td>"
                    + "<td style='text-align:center'>"+(i+1)+"</td>"
                    +"<td style='text-align:center'>" +data[i].nameZh+"</td>"
                    +"<td style='text-align:center'>"+data[i].description+"</td>"           
                    +"</tr>"                   
           		 }
           	// alert(str);
           	$("#roles").append(str);
			}
		});
	}
	function selectAll(obj){
		if($(obj).is(":checked")){
			$("input[name=checkall]").each(function(){
				   $(this).prop("checked", "true");
				});
		}else{
			$("input[name=checkall]").each(function(){
				   $(this).removeAttr("checked");
				});
		}
	}
	function save(){
		var value=[];
		$("input[name='checkall']:checked").each(function(){
			value.push($(this).val());
		});
		$.ajax({
			type : "post",
			data : {
				"repositoryId" : zTreeId,
				"classesId" : value
			},
			url : "knowledgeEditDataQueryJurisdictionDomain.do",
			dataType : "json",
			traditional : true,
			beforeSend : function(XMLHttpRequest) {},
			success : function(){
				 var index = parent.layer.getFrameIndex(window.name); 
				 window.parent.addRepository();
           		 parent.layer.msg('编辑成功!');
            	 parent.layer.close(index); 
            	 
			},
		});
	}
	
</script>
